home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
WINMODE.ARJ
/
WINMODE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-19
|
4KB
|
93 lines
/*+--------------------------------------------------------+
| WINMODE V1.0 FOR WINDOWS 3.1 |
| Copyright (c) 1988-92 Finnegan O'Malley & Company Inc. |
| All Rights Reserved |
| First Published in PC Magazine, May 12, 1992 [p.345] |
| |
| Developed under Microsoft C 5.1 |
+--------------------------------------------------------+
*/
/* -----------------------------------------------------
Altered/tested/debugged using Turbo C v2.0 by
Andy K. Have not done extensive tests...if you find
bugs I'd appreciate knowing about it. Thanks!!
Use with a command-line parameter to get the
copyright/info notice (ie WINMODE X ).
-----------------------------------------------------
*/
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#define INT_MULTIPLEX 0x2F
/* return codes ("errorlevel") available to a .BAT file */
#define MODE_DOS 0 /* running DOS */
#define MODE_DOS_TS 1 /* running DOS Task Switcher */
#define MODE_WIN3X_STD 2 /* running WIN ver 3x Standard mode */
#define MODE_WIN3X_2X 3 /* running WIN 386 ver 2x */
#define MODE_WINX_386E 4 /* running WIN virtual86 mode on 386/486 */
main(argc, argv)
int argc;
char *argv[];
{
auto struct SREGS Seg; /* segment registers */
static union REGS Reg; /* general registers */
if(argc != 1)
printf("%s 1.0 for Windows 3.1\n"
"Copyright (c) 1988-92 Finnegan O'Malley"
" & Company Inc. All Rights Reserved.\n"
"First Published in PC Magazine,"
" May 12, 1992.\n\n",argv[0]);
segread(&Seg); /* initialize the segment registers */
Reg.x.ax = 0x1600; /* in 386 enhanced mode? */
int86x(INT_MULTIPLEX, &Reg, &Reg, &Seg);
switch (Reg.h.al)
{
case 0x00: /* not in 386 Enhanced mode */
case 0x80: /* not in 386 Enhanced mode */
break;
case 0x01: /* Windows/386 2.xx is running */
case 0xFF: /* Windows/386 2.xx is running */
printf("Windows/386 2.xx is running (%d)\n",
MODE_WIN3X_2X );
exit(MODE_WIN3X_2X - '0');
default: /* in 386 Enhanced mode, where:
AL = major version (3., 4., ...)
AH = minor version (00, 10, ...) */
printf("Windows %d.%02d is running in 386 Enhanced"
" mode (%d)\n",Reg.h.al, Reg.h.ah,
MODE_WINX_386E);
exit(MODE_WINX_386E - '0');
}
Reg.x.ax = 0x4680; /* in plain vanilla DOS mode? */
int86x(INT_MULTIPLEX, &Reg, &Reg, &Seg);
if(Reg.h.al == 0x80){ /* not in DOS Task Switcher,
Real or Standard mode */
printf("Windows is not running, nor is the DOS"
" Task Switcher (%d)\n",
MODE_DOS);
exit(MODE_DOS - '0');
}
if(getenv("windir") /* in Real or Standard mode? */
|| getenv("WINDIR")) { /* in case it goes upper case */
printf("Windows 3.xx is running in Real or Standard"
" mode (%d)\n",
MODE_WIN3X_STD);
exit(MODE_WIN3X_STD - '0');
}
/* Otherwise, the DOS MS-DOS Shell is running */
printf("The DOS Task Switcher is running (%d)\n",
MODE_DOS_TS);
exit(MODE_DOS_TS - '0');
}